<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>模版页面</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css" />
		<link rel="stylesheet" href="../css/main.css" />
		<link rel="stylesheet" href="../css/mui.picker.css" />
		<link rel="stylesheet" href="../css/mui.poppicker.css" />
		<link rel="stylesheet" href="../css/feedback.css" />
		<!--图标-->
		<link rel="stylesheet" type="text/css" href="../css/icons-extra.css" />

		<style>
			.mui-table-view-chevron .mui-table-view-cell>a:not(.mui-btn) {
				margin-right: -115px;
			}
			.imgmsg {
				/* width: 80%; */
				max-width: 45%;
				margin: 0 auto;
				display: table;
				padding-top: 50px;
			}
			/*.mui-table-view:after {
				position: absolute;
				right: 0;
				bottom: 0;
				left: 0;
				height: 0px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}*/
			.mui-content{
				background: #fff;
			}
			.mui-table-view {
				margin-top: 0px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="padding-top:5%;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="ptitle">患者列表</h1>
		</header>
		<div class="mui-content mui-scroll-wrapper" id="content">
			
				<div class="mui-scroll">
					<ul class="mui-table-view mui-table-view-chevron" id="messageUL">

					</ul>
				</div>
		</div>
	</body>
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/app.js"></script>
	<script type="text/javascript" src="../js/constants.js"></script>
	<script type="text/javascript" src="../js/sharemethods.js"></script>
	<script type="text/javascript" src="../js/xiangyingshi.js"></script>
	<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
	
	<script type="text/javascript" src="../plugs/moment/moment.min.js"></script>
	<script type="text/javascript" src="../plugs/art/template-web.js"></script>
	<script type="text/javascript" src="../plugs/qs/qs.art.extend.js"></script>
	<script type="text/javascript" src="../plugs/qs/qs.template.js"></script>
	<script>
		var page = 1;
		var limit = 5;
		var pulldownEnd = false;
		mui.init({
			swipeBack: true, //启用右滑关闭功能
			pullRefresh: {
				container: "#content", //下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
				down: {
					callback: pulldownRefresh
				}
			}
		});

		function pulldownRefresh() {
			setTimeout(function() {
				if(!pulldownEnd) {
					var table = document.body.querySelector('.mui-table-view');

					var sussess = function(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						if(data.result == "success") {
							if(data.obj.length < limit) {
								pulldownEnd = true;
							} else {
								page = page + 1;
							}
							console.log(JSON.stringify(data))
							data.obj.forEach(function(v, i) {
								$("#messageUL").processTL(templateRegister.patientsList, v, 'prepend')
							});
						} else {
							mui.toast(data.msg);
						}
					};
					commonHttpUtils(getpatientsUrl + "?page=" + page + "&limit=" + limit, "get", "", sussess, error);

				} else {
					mui.toast("没有更多消息了");
				}
				mui('#content').pullRefresh().endPulldownToRefresh(); //refresh completed
			}, 1500);

		}

		mui.plusReady(function() {
			setPagePos();
			var currentView = plus.webview.currentWebview();
			currentView.show('slide-in-right', 200);
			plus.nativeUI.closeWaiting();

			init()
		});


		function init() {
			page = 1;
			var sussess = function(data) {
				//服务器返回响应，根据响应结果，分析是否登录成功；
				console.log(JSON.stringify(data))
				if(data.result == "success") {
					if(data.obj.length == 0) {
						$('#messageUL').html('<p id="emptyImg"><img class="imgmsg" src="../images/no_data/1-03.png" data-preview-src="" data-preview-group="1"></p>')
					} else {
						$('#messageUL').html()
						if(data.obj.length < limit) {
							pulldownEnd = true;
						} else {
							page = page + 1;
						}
						data.obj.forEach(function(v, i) {
							console.log(JSON.stringify(v))
							console.log(v)
							$("#messageUL").processTL(templateRegister.patientsList, v, 'prepend')
						});
					}
				} else {
					mui.toast(data.msg);
				}
			};
			commonHttpUtils(getpatientsUrl + "?page=" + page + "&limit=" + limit, "get", "", sussess, error);
		}
	</script>

</html>